//多选框点击事件
function check(){
    let chek = document.querySelector('.con p:nth-child(8) input')
    let submit = document.getElementById('submit')
    chek.onclick=()=>{
        if(!chek.checked){
            submit.disabled=true
            submit.classList.remove('on')
        }else{
            submit.disabled=false
            submit.classList.add('on')
        }
    }
}
check()

let submit = document.getElementById('submit')
let user = document.getElementById('userName')
let tel = document.getElementById('tel')
let code = document.getElementById('code')
let yzm = document.getElementById('yzm')
let paw = document.getElementById('paw')
let timerId = null
let lis = document.querySelectorAll('form>div>p')
let p1 = document.querySelector('form div:nth-child(4) p')
let p2 = document.querySelector('form div:nth-child(5) p')
let p3 = document.querySelector('form div:nth-child(6) p')
let p4 = document.querySelector('form div:nth-child(7) p')
submit.onclick=()=>{
    if(user.value.length<6 || user.value.length>12){
        p1.classList.add('on')
    }else if(tel.value.length!==11){
        p2.classList.add('on')
    }else if(code.value.length!==4){
        p3.classList.add('on')
    }else if(paw.value.length<6 || paw.value.length>12){
        p3.classList.add('on')
    }else{
        alert('恭喜注册成功！')
        timerId = setTimeout(function(){
            location='./index.html' 
        },2000)
    }
}
user.onblur=()=>{
    if(user.value.length>5 && user.value.length<13){
        p1.classList.remove('on')
    }else{
        p1.classList.add('on')
    }
}
tel.onblur=()=>{
    if(tel.value.length!==11){
        p2.classList.add('on')
    }else{
        p2.classList.remove('on')
    }
}
code.onblur=()=>{
    if(code.value.length!==4){
        p3.classList.add('on')
    }else{
        p3.classList.remove('on')
    }
}
paw.onblur=()=>{
    if(paw.value.length>5 && paw.value.length<13){
        p4.classList.remove('on')
    }else{
        p4.classList.add('on')
    }
}
yzm.onclick=()=>{
    clearInterval(timerId)
    let num = 60
    yzm.disabled=true
    yzm.value=num
    timerId = setInterval(()=>{
        --num
        yzm.value=num
        if(num==0){
            yzm.value='获取验证码'
            yzm.disabled=false
            clearInterval(timerId)
        }
              
    },1000)
}
